<%@page import="java.util.TreeMap"%>
<%@page import="com.tubeonfire.model.admin.SiteConfigModel"%>
<%@page import="com.tubeonfire.entity.SiteConfig"%>
<%@page import="com.tubeonfire.entity.Feedback"%>
<%@page import="java.util.List"%>
<%@page import="net.tanesha.recaptcha.ReCaptchaFactory"%>
<%@page import="net.tanesha.recaptcha.ReCaptcha"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	SiteConfig siteConfig = SiteConfigModel.get();	
	String logoUrl = siteConfig.getLogoKey();
	if(!logoUrl.equals("/images/logo.png")){ 
		logoUrl = "http://" + request.getServerName() + "/image?key=" + logoUrl + "&size=250";	
	}
	String siteName = siteConfig.getSiteName();
	String pageUrl = (String)request.getAttribute("url");
	String pageTitle = "Contact Us";
	String pageName = siteConfig.getSiteName();
	String pageDescription = siteConfig.getSiteDescription();
	String pageKeyword = siteConfig.getSiteKeyword();
	String pageImage = logoUrl;
	String facebookAdminId = siteConfig.getFacebookAdminId();	
	String pageLogoUrl = logoUrl;
	String pageLogoSlogan = siteConfig.getLogoSlogan();
	String analyticCode = siteConfig.getAnalyticCode();	
%>
<jsp:include page="/element/header.jsp">
	<jsp:param name="siteName" value="<%= siteName %>"/>	
	<jsp:param name="pageUrl" value="<%= pageUrl %>"/>
	<jsp:param name="pageTitle" value="<%=pageTitle %>"/>	
	<jsp:param name="pageName" value="<%=pageName %>"/>
	<jsp:param name="pageImages" value="<%=pageImage %>"/>
	<jsp:param name="pageKeyword" value="<%=pageKeyword %>"/>
	<jsp:param name="pageDescription" value="<%=pageDescription %>"/>
	<jsp:param name="facebookAdminId" value="<%=facebookAdminId %>"/>
	<jsp:param name="pageLogoUrl" value="<%=pageLogoUrl %>"/>
	<jsp:param name="pageLogoSlogan" value="<%=pageLogoSlogan %>"/>
</jsp:include>
<%
	TreeMap<String, String> check = (TreeMap<String, String>) request.getAttribute("check");
	String success = (String) request.getAttribute("success");
	Feedback obj = (Feedback)request.getAttribute("feedback");
%>
<script src="/js/jquery.validate.min.js"></script>
<style type="text/css">
	.error {
		color: #FB3A3A;
		padding-left: 10px;			 
	}    
</style>
<script>
(function($,W,D)
		{
		    var JQUERY4U = {};
		    JQUERY4U.UTIL =
		    {
		        setupFormValidation: function()
		        {
		            //form validation rules
		            $("#register-form").validate({
		                rules: {
		                    name: "required",
		                    title: "required",
		                    email: {
		                        required: true,
		                        email: true
		                    },
		                    message: {
		                        required: true,
		                        minlength: 5
		                    },	
							recaptcha_response_field: "required",                   
		                },
		                messages: {
		                    name: "Please enter your name",		
		                    title: {
		                        required: "Please enter message title",                       
		                    },
		                    email: "Please enter a valid email address",
		                    message: "Please enter message content",
							recaptcha_response_field: "Please enter captcha text",
		                },
		                submitHandler: function(form) {
		                    form.submit();
		                }
		            });
		        }
		    }
		    //when the dom has loaded setup form validation rules
		    $(D).ready(function($) {
		        JQUERY4U.UTIL.setupFormValidation();
		    });

		})(jQuery, window, document);
</script>
        <header>             
            <div id="header">            	
                <div id="header_inner">
                	<div id="contact-page">                		
		        		<h2 class="contact-title">Contact Us</h2>
       					<p class="contact-text">
       						<%
       							if(success!=null&&success.length()>0){
       								%>
       								<p class="success-text"><%=success %></p>
       								<%
       							}else{
       								%>
       								(If you have any questions or request, please contact us ! )			
     								<%
       							}
       						%>       					       					
       					</p>	
       					<%
       						if(check!=null&&check.size()>0){       							
      							%>
      							<p class="error-text">* Please fix below error to send your message</p>
      							<%       							
       						}	                					
       					%>  
       					<form id="register-form" action="/contact-us" method="post">
			        		<table style="padding: 4px; margin: 4px">
			        			<tr>
			        				<td align="right">
			        					<p class="contact-text">Name <span style="color: red">*</span></p> 
		        					</td>
			        				<td>						        					
			        					<input type="hidden" name="action" value="contact"/>
			        					<input type="text" name="name" title="name" style="width: 200px; height: 20px" value="<%=(obj!=null&&obj.getName()!=null)?obj.getName():""%>" />
			        					<%
			        						if(check!=null&&check.containsKey("name")){
			        							%>
		        								<label for="name" generated="true" class="error"><%=check.get("name") %></label>			        								
			        							<%
			        						}
		        						%>			        					
		        					</td>
			        			</tr>
			        			<tr>
			        				<td align="right">
			        					<p class="contact-text">Email <span style="color: red">*</span></p> 
		        					</td>
			        				<td>						        					
			        					<input type="hidden" name="action" value="register"/>
			        					<input type="text" name="email" title="email" style="width: 200px; height: 20px" value="<%=(obj!=null&&obj.getEmail()!=null)?obj.getEmail():""%>" />
			        					<%
			        						if(check!=null&&check.containsKey("email")){
			        							%>
			        							<label for="email" generated="true" class="error"><%=check.get("email") %></label>					        								
			        							<%
			        						}
		        						%>
		        					</td>
			        			</tr>
			        			<tr>
			        				<td align="right">
			        					<p class="contact-text">Title <span style="color: red">*</span></p> 
		        					</td>
			        				<td>						        					
			        					<input type="hidden" name="action" value="register"/>
			        					<input type="text" name="title" title="title" style="width: 440px; height: 20px" value="<%=(obj!=null&&obj.getTitle()!=null)?obj.getTitle():""%>" />
			        					<%
			        						if(check!=null&&check.containsKey("title")){
			        							%>
			        							<label for="title" generated="true" class="error"><%=check.get("title") %></label>				        							
			        							<%
			        						}
		        						%>
		        					</td>
			        			</tr>
			        			<tr>
			        				<td align="right">
			        					<p class="contact-text">Message <span style="color: red">*</span></p>
		        					</td>
			        				<td>
			        					<textarea name="message" style="width: 438px; height: 100px"><%=(obj!=null&&obj.getMessage()!=null)?obj.getMessage():""%></textarea>
			        					<%
			        						if(check!=null&&check.containsKey("message")){
			        							%>
			        							<label for="message" generated="true" class="error"><%=check.get("message") %></label>				        							
			        							<%
			        						}
		        						%>			        								        					
		        					</td>
			        			</tr>			        			
			        			<tr>
			        				<td align="right">						        					
		        					</td>
			        				<td>
			        					<script>
						        			var RecaptchaOptions = { theme : 'clean' };
								  		</script>
										<%														
								          ReCaptcha c = ReCaptchaFactory.newReCaptcha("6LfUNtESAAAAACod-aFeQ8UfSUeF-nDDNyJifahX", "6LfUNtESAAAAANSiC1e3dD974bMUFY21S5QANakS", false);
								          out.print(c.createRecaptchaHtml(null, null));
								        %>
								        <%
			        						if(check!=null&&check.containsKey("capcha")){
			        							%>
			        							<label for="capcha" generated="true" class="error"><%=check.get("capcha") %></label>			        							
			        							<%
			        						}
		        						%>	
		        					</td>
			        			</tr>						        			 
			        			<tr>
			        				<td>
			        					 
		        					</td>
			        				<td>
			        					<input class="button green" type="submit" value="Submit"/>
			        					<input class="button green" type="reset" value="Reset"/>
		        					</td>
			        			</tr>						        						        	
			        		</table>		        		
		        		</form>	                  		        
		        	</div>                 
                </div>
                <div class="clearbreak"></div>                
            </div>
        </header>        
<jsp:include page="/element/footer.jsp">
	<jsp:param name="analyticCode" value="<%= analyticCode %>"/>
</jsp:include>